﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;

namespace MyStream.Core
{
    public class VersionControlService
    {
        public static List<string> GetWorkSpace()
        {
            List<string> results = null;
            foreach (TeamFoundationServer tfs in RegisteredServers.GetServers())
            {
                VersionControlServer tfvc = tfs.GetService(typeof(VersionControlServer)) as VersionControlServer;
                Workspace[] wss = tfvc.QueryWorkspaces(null, tfvc.AuthenticatedUser.Split('\\')[1], Environment.MachineName);
                foreach (Workspace ws in wss)
                {
                    if (results == null)
                        results = new List<string>();
                    results.Add(ws.Name + " on " + tfs.Name);
                }
            }
            return results;
        }
    }
}
